import axios from './config'
import { AxiosPromise } from 'axios'
import {IrateList, IrateScore, IrateTag, IShopList, IshopListQuery} from './config/responseType'
/**
 * 获取商铺详情
 */
//参数接口
interface reqShopDetailsArgInterface {
    restaurant_id:string | (string | null)[] ,
    geohash:string | (string | null)[],
}
export const reqShopDetails = (params:reqShopDetailsArgInterface):AxiosPromise<IShopList[]>=>{
    return axios.request({
        url:'/shopping/restaurant/' + params.restaurant_id,
        data: {
            geohash: JSON.stringify(params.geohash).split(',')[0].replace("\"",""),
            longitude: JSON.stringify(params.geohash).split(',')[1].replace("\"","") + '&extras[]=activities&extras[]=album&extras[]=license&extras[]=identification&extras[]=statistics'
        },
        method:'GET'
    })
}

/**
 * 获取商铺评价列表
 */
//参数接口
interface reqRatingListArgInterface {
    restaurant_id:string | (string | null)[] ,
    offset:number,
    tag_name:string,
    limit:number,
}
export const reqRatingList = (params:reqRatingListArgInterface):AxiosPromise<IrateList[]> =>{
    return axios.request({
        url:'/ugc/v2/restaurants/' + params.restaurant_id + '/ratings',
        params:params,
        method:'GET',
    })
}

/**
 * 根据经纬度获取商铺列表
 */

export const reqShopList = (params:IshopListQuery):AxiosPromise<IShopList[]> => {
    return axios.request({
        url:'/shopping/restaurants',
        params:params,
        method: 'GET'
    })
}

/**
 * 获取商铺评价分数
 */
export const reqRatingScores = (restaurant_id: string | (string | null)[]):AxiosPromise<IrateScore> =>{
    return axios.request({
        url:'/ugc/v2/restaurants/' + restaurant_id + '/ratings/scores',
        method: 'GET'
    })
}

/**
 * 获取评价分类
 */
export const ratingTags = (restaurant_id: string | (string | null)[]):AxiosPromise<IrateTag[]> => {
    return axios.request({
        url:'/ugc/v2/restaurants/'+restaurant_id+'/ratings/tags',
        method: 'GET'
    })
}
